<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
    <title>excel</title>
    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>
</head>
<body>

<div class="container" id="app">
    <input type="button" value="下载excel" v-on:click="exportExcel">
</div>

<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            code: '',
            noData: false,
            Datum: []
        },
        methods: {
            exportExcel: function () {
                axios.get('/excel/export', {responseType: 'blob'})
                    .then(function (res) {
                        const link = document.createElement('a')
                        var blob = new Blob([res.data], {type: 'application/vnd.ms-excel'});
                        link.style.display = 'none'
                        link.href = URL.createObjectURL(blob);
                        link.download = '伟哥.xlsx';
                        document.body.appendChild(link)
                        link.click()
                        document.body.removeChild(link)
                    })
                    .catch(function (error) {

                    })
            }
        }
    })
</script>
</body>
</html>
